﻿using System.Collections.Generic;
using Microsoft.Data.Schema.ScriptDom.Sql;

namespace Neznayka
{
    internal class TableVariableDeclarationVisitor : TSqlConcreteFragmentVisitor
    {
        private List<Literal> _targets;

        #region ctor
        public TableVariableDeclarationVisitor()
        {
            _targets = new List<Literal>();
        }
        #endregion

        #region properties
        public List<Literal> TableVariableDeclarations
        {
            get { return _targets; }
        }
        #endregion

        #region overrides
        public override void ExplicitVisit(DeclareTableBody node)
        {
            // whey-hey
            // inline row-producing functions use this and don't have a variable associated with them
            if (node.VariableName != null)
            {
                _targets.Add(node.VariableName);
            }
        }
        #endregion

    }


}